package com.erp.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.erp.common.R;
import com.erp.entity.Employee;
import com.erp.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/employee")
public class EmployeeController {

    @Autowired
    private EmployeeService employeeService;

    @PostMapping
    public R<String> add(@RequestBody Employee employee){
        boolean save = employeeService.save(employee);

        if (save){
            return R.success("新增成功");
        }else {
            return R.error("错误");
        }
    }

    @GetMapping
    public R<Employee> find(Long id){
        Employee byId = employeeService.getById(id);
        if(byId==null){
            return R.error("ID错误");
        }else {
            return R.success(byId);
        }
    }



}
